package o;

import android.graphics.Rect;
import android.view.Window;
import android.view.WindowManager.LayoutParams;
import androidx.annotation.NonNull;
import java.lang.reflect.InvocationTargetException;

public class ayy {
    private static ayy ˊ;
    private static final Object ॱ = new Object();
    private Rect ˎ = new Rect();

    public static ayy ˋ() {
        ayy o_ayy;
        synchronized (ॱ) {
            if (ˊ == null) {
                ˊ = new ayy();
            }
            o_ayy = ˊ;
        }
        return o_ayy;
    }

    public void ॱ() {
        if (azc.ˎ().ॱ() >= 21) {
            this.ˎ = ᐝ();
            ayv.ˎ.ˎ("HwDisplaySafeInsetsUtils", "displaySafeInsets=" + this.ˎ + ", left=" + this.ˎ.left + ", right=" + this.ˎ.right);
            return;
        }
        ayv.ˎ.ˏ("HwDisplaySafeInsetsUtils", "the version sdk api < 28, need not get display safe insets.");
    }

    private static Rect ᐝ() {
        try {
            Object invoke = Class.forName("com.huawei.android.view.ExtDisplaySizeUtilEx").getMethod("getDisplaySafeInsets", new Class[0]).invoke(null, new Object[0]);
            if (invoke instanceof Rect) {
                return (Rect) invoke;
            }
            ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "getDisplaySafeInsets: object is not Rect");
            return new Rect();
        } catch (ClassNotFoundException e) {
            ayv.ˎ.ˏ("HwDisplaySafeInsetsUtils", "getDisplaySafeInsets: class not found");
            return new Rect();
        } catch (NoSuchMethodException e2) {
            ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "getDisplaySafeInsets: method not found");
            return new Rect();
        } catch (IllegalAccessException e3) {
            ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "getDisplaySafeInsets: illegal access exception");
            return new Rect();
        } catch (InvocationTargetException e4) {
            ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "getDisplaySafeInsets: invocation target exception");
            return new Rect();
        }
    }

    public void ˎ(@NonNull Window window) {
        if (azc.ˎ().ॱ() >= 21) {
            LayoutParams attributes = window.getAttributes();
            try {
                Class cls = Class.forName("com.huawei.android.view.WindowManagerEx$LayoutParamsEx");
                Object newInstance = cls.getConstructor(new Class[]{LayoutParams.class}).newInstance(new Object[]{attributes});
                cls.getMethod("setDisplaySideMode", new Class[]{Integer.TYPE}).invoke(newInstance, new Object[]{Integer.valueOf(1)});
            } catch (ClassNotFoundException e) {
                ayv.ˎ.ˏ("HwDisplaySafeInsetsUtils", "setWindowDisplaySideMode: class not found");
            } catch (NoSuchMethodException e2) {
                ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "setWindowDisplaySideMode: method not found");
            } catch (IllegalAccessException e3) {
                ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "setWindowDisplaySideMode: illegal access exception");
            } catch (InstantiationException e4) {
                ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "setWindowDisplaySideMode: InstantiationException exception");
            } catch (InvocationTargetException e5) {
                ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "setWindowDisplaySideMode: invocation target exception");
            } catch (Exception e6) {
                ayv.ˎ.ˊ("HwDisplaySafeInsetsUtils", "setWindowDisplaySideMode: exception");
            }
        }
    }

    public boolean ˎ() {
        return this.ˎ.left > 0 || this.ˎ.right > 0;
    }

    public int ˏ() {
        return this.ˎ.left;
    }

    public int ˊ() {
        return this.ˎ.right;
    }
}
